%option noyywrap nounput
%option bison-bridge reentrant

%{
#include <stdio.h>
#include "SmtpCommandsParser.h"
	
#define YYSTYPE char*
	
#define YY_USER_INIT FlexUserInit(yylval, yyscanner)
	
void FlexUserInit(YYSTYPE* bisonStackPtr, yyscan_t scanner)
{
	fprintf(stderr, "In FlexUserInit()\n");
	fprintf(stderr, "bisonStackPtr is %p, scanner is %p\n", bisonStackPtr, scanner);
}
%}

%%
[ /t]	return SPACE;
\r\n	return CRLF;
:		return COLON;
\<		return LEFT_ANGLE_BRACKET;
>		return RIGHT_ANGLE_BRACKET;
@		return AT;
ehlo						*yylval = strdup(yytext); printf("Flex: COMMAND_WITH_DOMAIN: %s; ", yytext); return COMMAND_WITH_DOMAIN;
mail[ ]from|rcpt[ ]to		*yylval = strdup(yytext); printf("Flex: COMMAND_WITH_ADDRESS: %s; ", yytext); return COMMAND_WITH_ADDRESS;
data[ ]						*yylval = strdup(yytext); printf("Flex: COMMAND_WITH_DATA: %s; ", yytext); return COMMAND_WITH_DATA;
noop|rset|quit				*yylval = strdup(yytext); printf("Flex: CONTROL_COMMAND: %s; ", yytext); return CONTROL_COMMAND;
[A-Za-z0-9.-]+\.[A-Z]{2,6}	*yylval = strdup(yytext); printf("DOMAIN: %s; ", yytext); return DOMAIN;
[A-Za-z0-9._%+-]+			*yylval = strdup(yytext); printf("LOCAL_PART: %s; ", yytext); return LOCAL_PART;
%%